<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>测试</title>
</head>

<body>
    <!-- <script>
        function sleep(millisecond) {
  return new Promise(resolve => {
    setTimeout(() => resolve, millisecond)
  })
}

/**
 * 以下是测试代码
 */
async function test() {
  console.log('start')
  await sleep(1000) // 睡眠1秒
  console.log('end')
  return 'done';
}

test().then(val=>{
    console.log(val);
    
}) // 执行测试函数


    </script> -->

    <script>
        function sleep(second) {
            return new Promise(resolve => {
                setTimeout(() => {
                    console.log(Math.random());
                    resolve();
                }, second);
            });
        }

        async function chuanXingDemo() {
            await sleep(1000);
            await sleep(1000);
            await sleep(1000);
        }


        async function bingXingDemo() {
            var tasks = [];
            for (let i = 0; i < 3; ++i) {
                tasks.push(sleep(1000));
            }

            await Promise.all(tasks);
        }

        chuanXingDemo()
        bingXingDemo()
    </script>

</body>

</html>